def function-name(argument1,argument2,..): statements ---------- return value
def interest(p,r,n): si=p*r*n/100 return si z=interest(5000,10.25,3) print ("Simple interest is ",z)
Simple Interest is 1537.50
def volume(l,b,h): v=l * b * h return v z=volume(5,4,3) print ("Volume is ",z)
Volume is 60
def area(r): a=3.14*r**2 return a def circumference(r): c=2*3.14*r return c n=input("Enter Radius:") n=int(n) print("Area is",area(n)) print("Circumference is",circumference(n))
Enter Radius: 5 Area is 78.5 Circumference is 31.4
def sum(n): s=0 for i in range(1,n+1): s=s+i return s z=sum(5) print("Result is " , z)
Result is 15
def fact(n): f=1 for i in range(1,n+1): f=f*i return f z=fact(5) print("Result is " , z)
Result is 120
def isprime(n): for i in range(2,n): if n%i==0: return False else: return True a=int(input("Enter a Number:")) if isprime(a) : print(a,"is Prime Number") else: print(a,"is Not Prime Number")
Enter a Number: 25 25 is not a Prime Number Enter a Number: 23 23 is a Prime Number